﻿using System;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;
using UDS.Components;

namespace UDS.SubModule.StaffPages
{
    /// <summary>
    /// Search 的摘要说明。
    /// </summary>
    public partial class SearchPage : Page
    {
        protected override void OnInit(EventArgs e)
        {
            lbtn_Others.Click += (lbtn_Others_Click);
            base.OnInit(e);
        }

        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                table_Other.Visible = false;
                BindPosition();
            }

            base.OnLoad(e);
        }

        private void BindPosition()
        {
            var db = new Database();
            using (SqlDataReader dr = db.RunDataReader("dbo.sproc_Ext_GetPosition"))
            {
                ddl_Position.DataSource = dr;
                ddl_Position.DataTextField = "Position_Name";
                ddl_Position.DataValueField = "Position_ID";
                ddl_Position.DataBind();
            }

            ddl_Position.Items.Insert(0, new ListItem("全部", "0"));
        }

        private void lbtn_Others_Click(object sender, EventArgs e)
        {
            table_Other.Visible = !table_Other.Visible;
            lbtn_Others.Text = table_Other.Visible ? "其它查询<<<" : "其它查询>>>";
        }
    }
}